home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
8_6.lha
/
8_6
/
ostream.h
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
49 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
lass ostream
riend istream;
streambuf *bp;
state_value state;
ublic:
ostream& operator<<(const char*); // write
ostream& operator<<(int a) { return *this<<long(a); }
ostream& operator<<(unsigned a)
{ return *this<<(unsigned long) a; }
ostream& operator<<(unsigned long);
ostream& operator<<(long); // beware: << 'a' writes 97
ostream& operator<<(double);
ostream& operator<<(const streambuf&);
ostream& operator<<(const whitespace&);
/ ostream& operator<<(const common&);
ostream& put(char); // put('a') writes a
ostream& flush() { bp->overflow(); return *this; }
operator void*(){ return _eof<state?0:this; }
int operator!() { return _eof<state; }
int eof() { return state&_eof; }
int fail() { return _eof<state; }
int bad() { return _fail<state; }
int good() { return state==_good; }
void clear(state_value i =0) { state=i; }
int rdstate() { return state; }
/ char* bufptr() { return bp->base; }
ostream(streambuf* s) { bp = s; state = 0; }
ostream(FILE *fp) { bp = new filebuf(fp); state = 0; }
ostream(int size, char* p)
{
state = 0;
bp = new streambuf();
if (p == 0) p = new char[size];
bp->setbuf(p, size);
}
~ostream() { flush(); }
;